package com.xw.comm.utils;

import gnu.io.CommPortIdentifier;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

/**
 * 串口的一些工具类
 *
 * @author xiongwei_vendor
 * @date 2020/12/8 16:18
 */
@Slf4j
public class SerialUtil {

    public static List<String> getCommon() {
        List<String> commList = new ArrayList<>();
        Enumeration<CommPortIdentifier> em = CommPortIdentifier.getPortIdentifiers();
        while (em.hasMoreElements()) {
            String name = em.nextElement().getName();
            commList.add(name);
            log.info("name = {}",name);
        }
        return commList;
    }

}
